// script.js
let todos = [];
function addTodo() {
    const input = document.getElementById('todoInput');
    const text = input.value.trim();
    if (text) {
        todos.push({ text, completed: false });
        input.value = '';
        renderTodos();
    }
}
function toggleTodo(index) {
    todos[index].completed = !todos[index].completed;
    renderTodos();
}
function renderTodos() {
    const list = document.getElementById('todoList');
    list.innerHTML = todos.map((todo, index) => 
        `<li onclick="toggleTodo(${index})" class="${todo.completed ? 'completed' : ''}">${todo.text}</li>`
    ).join('');
}